#%RAML 0.8
title: Cello
baseUri: www.cellocad.org
securitySchemes:
  - basic:
      type: Basic Authentication


/in_out:
  get:
    securedBy: [basic]
    description: Get a list of input promoter and output gene file names.
    responses:
      200:
        description: 
        body:
           application/json:
            example: |
              {
                "files" : ['input_pBAD.txt','input_pBM3R1.txt','input_pLuxStar.txt','input_pTac.txt','input_pTet.txt','output_BFP.txt','output_RFP.txt','output_YFP.txt']
              }
              
  /{filename}:
    get:
      securedBy: [basic]
      description: Get file contents of the specified input promoter file or output gene file.
      responses:
        200:
          description: Column-separated text.  An input promoter contains a name, low RPU, high RPU, and promoter DNA sequence.  An output gene contains a name and DNA sequence, where the DNA sequence will typically contain a ribozyme, RBS, CDS, and terminator concatenated into a single sequence.
          body:
            text/plain:
              example: |
                pBAD 0.0082 2.5 ACTTTTCATACTCCCGCCATTCAGAGAAGAAACCAATTGTCCATATTGCATCAGACATTGCCGTCACTGCGTCTTTTACTGGCTCTTCTCGCTAACCAAACCGGTAACCCCGCTTATTAAAAGCATTCTGTAACAAAGCGGGACCAAAGCCATGACAAAAACGCGTAACAAAAGTGTCTATAATCACGGCAGAAAAGTCCACATTGATTATTTGCACGGCGTCACACTTTGCTATGCCATAGCATTTTTATCCATAAGATTAGCGGATCCTACCTGACGCTTTTTATCGCAACTCTCTACTGTTTCTCCATACCCGTTTTTTTGGGCTAGC
        404:
          body:
            application/json:
              example: |
                {
                  "message": "file input_pBAD.txt does not exist"
                } 
                
    post:
      securedBy: [basic]
      description: Write a file with the specified text.
      queryParameters:
        filetext:
          description: Contents to be written to file.
          type: string
          required: true
      responses:
        200:
          description:
          body:
            application/json:
              example: |
                {
                  "message": "wrote file input_pPhlF.txt"
                }

    delete:
      securedBy: [basic]
      description: Delete file.
      responses:
        200:
          body:
            application/json:
              example: |
                {
                  "message": "deleted file input_pPhlF.txt"
                }
        404:
          body:
            application/json:
              example: |
                {
                  "message": "file input_pPhlF.txt does not exist"
                }

      
/netsynth:
  post:
    securedBy: [basic]
    description: A Verilog logic specification is convered to wiring diagram (NOR/NOT gates) through logic synthesis.  The result is not the final netlist; this endpoint serves to validate the Verilog code.
    queryParameters:
      verilog_text:
        description: File contents of a Verilog .v logic specification.
        type: string
        required: true
    responses:
      200:
        body:
          text/plain:
            example: |
              0  OUTPUT      (1)         
              1  NOR         (3,2)       
              2  NOT         (5)         
              3  NOT         (4)         
              4  INPUT                   
              5  INPUT     
      500:
        description: If the Verilog is not valid, errors within NetSynth result in a status 500 error.
        body:
          application/json:
            example: |
              {"timestamp":1450706258636,"status":500,"error":"Internal Server Error","exception":"java.lang.StringIndexOutOfBoundsException","message":"String index out of range: -1","path":"/netsynth"} 

/submit:
  post:
    securedBy: [basic]    
    description: Run Cello!
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "message": "SUCCESS: Loading results page."
              }
    queryParameters:
      jobid:
        description: job name/identifier.  A valid name starts with a letter, and only contains letters, numbers, and underscores.  The regex for a valid name is [a-zA-Z][0-9a-zA-Z_]+
        type: string
        required: true
      verilog:
        description: Verilog text (not filepath)
        type: string
        required: true
      inputs:
        description: Input promoter data.  Rows of space-separated name, low, high, dnaseq
        type: string
        required: true
        example: | 
          pTac 0.0034 2.8 AACGATCGTTGGCTGTGTTGACAATTAATCATCGGCTCGTATAATGTGTGGAATTGTGAGCGCTCACAATT
      outputs:
        description: Output gene data.  Rows of space-separated name, dnaseq (each dnaseq should concatenate ribozyme, rbs, cds, terminator)
        type: string
        required: true
        example: YFP CTGAAGCTGTCACCGGATGTGCTTTCCGGTCTGATGAGTCCGTGAGGACGAAAC
      user_options:
        description: custom flags, not intended for new users. Space + dash separated strings.
        type: string
        required: true
        example: |
          -figures false -plasmid false -assignment_algorithm hill_climbing
        
/results:
  get:
    securedBy: [basic]
    description: List of previous job names
    responses:
      200:
        body:
          application/json:
            example: |
              {
                "folders": ["job1", "majority_v2"]
              }
    
  /{jobid}:
    get:
      securedBy: [basic]
      description: List of files in job result folder
      queryParameters:
        keyword:
          description: Filter by substring within the file name
          required: false
          type: string
          example: "logic_circuit"
        extension:
          description: Filter by file extension
          required: false
          type: string
          example: ".txt"
      responses:
        200:
          description: Array of strings
                
    delete:
      securedBy: [basic]
      description: Delete previous job result
      responses:
        200:
          body:
            text/plain:
              example:
                deleted majority_v2
    
    /{filename}:
        get:
          description: Get file contents (text or png-bytes).  
          
/ucf:
  get:
    securedBy: [basic]
    description: Get a list of UCF's owned by the authenticated user.  UCF file names should end in the .UCF.json extension.  This list does not include the default UCF, Eco1C1G1T1.UCF.json.
    responses:
      200:
        description: 
        body:
           application/json:
            example: |
              {
                "files" : ['Eco2C2G2T2.UCF.json']
              }
  /{filename}:
    get:
      securedBy: [basic]
      description: Get the JSON for the specified UCF. This can be many Mb's of data.
      responses:
        200:
          description: 
          body:
             application/json:

    post:
      securedBy: [basic]
      description: Upload a new UCF.  The UCF JSON is in the request body, and the file name that will be created is the endpoint terminal.
      queryParameters:
        filetext:
          description: Contents to be written to file.
          type: string
          required: true
      responses:
        200:
          description: 
          body:
            application/json:
              example: |
                {
                  "message" : "wrote file Eco2C2G2T2.UCF.json"
                }
                
    delete:
      securedBy: [basic]
      description: Delete a UCF from the user's account.
      responses:
        200:
          description: 
          body:
             application/json:
               example: |
                {
                  "message" : "deleted file Eco2C2G2T2.UCF.json"
                }
    /validate:
      get:
        securedBy: [basic]
        description: Determine if an uploaded UCF is valid.
        responses:
          200:
            description: status is either "VALID" or "INVALID"
            body:
               application/json:
                example: |
                  {
                    "status":"VALID"
                  }
